package com.rimi.controller;

import com.rimi.bean.*;
import com.rimi.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;


@Controller
@RequestMapping("/listPage")
public class ListPageController {

    @Autowired
    private MenuTypeService menuTypeService;
    @Autowired
    private MenuAddressService menuAddressService;
    @Autowired
    private MenuService menuService;
    @Autowired
    private VideoService videoService;


    //把菜单列表发送到list_page
    @RequestMapping("index")
    public String getMenuList(Model model){
        List<MenuType> menuTypeList = menuTypeService.getMenuTypeList();
        List<MenuAddress> menuAddressList = menuAddressService.getMenuAddressList();
        List<Menu> menuList = menuService.getMenuList();
        List<Video> videoList = videoService.getVideoList();
        //把类型菜单存入MenuType

        model.addAttribute("MenuType", menuTypeList);
        for (MenuType menuType : menuTypeList) {
            System.out.println(menuType);
        }
        //把地区菜单存入MenuAddress
        model.addAttribute("MenuAddress", menuAddressList);
        //把主页菜单列表存入Menu
        model.addAttribute("Menu", menuList);
        //把视频海报存入VideoImage
        model.addAttribute("VideoImage", videoList);
        return "list_page";
    }


}
